package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.PurchaseOrderMapper;
import com.ruoyi.system.domain.PurchaseOrder;
import com.ruoyi.system.service.IPurchaseOrderService;
import com.ruoyi.common.core.text.Convert;

/**
 * 采购Service业务层处理
 * 
 * @author 华馨悦
 * @date 2025-01-24
 */
@Service
public class PurchaseOrderServiceImpl extends ServiceImpl<PurchaseOrderMapper,PurchaseOrder> implements IPurchaseOrderService

{
    @Autowired
    private PurchaseOrderMapper purchaseOrderMapper;

    /**
     * 查询采购
     * 
     * @param id 采购主键
     * @return 采购
     */
    @Override
    public PurchaseOrder selectPurchaseOrderById(Long id)
    {
        return purchaseOrderMapper.selectPurchaseOrderById(id);
    }

    /**
     * 查询采购列表
     * 
     * @param purchaseOrder 采购
     * @return 采购
     */
    @Override
    public List<PurchaseOrder> selectPurchaseOrderList(PurchaseOrder purchaseOrder)
    {
        return purchaseOrderMapper.selectPurchaseOrderList(purchaseOrder);
    }

    /**
     * 新增采购
     * 
     * @param purchaseOrder 采购
     * @return 结果
     */
    @Override
    public int insertPurchaseOrder(PurchaseOrder purchaseOrder)
    {
        return purchaseOrderMapper.insertPurchaseOrder(purchaseOrder);
    }

    /**
     * 修改采购
     * 
     * @param purchaseOrder 采购
     * @return 结果
     */
    @Override
    public int updatePurchaseOrder(PurchaseOrder purchaseOrder)
    {
        return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
    }

    /**
     * 批量删除采购
     * 
     * @param ids 需要删除的采购主键
     * @return 结果
     */
    @Override
    public int deletePurchaseOrderByIds(String ids)
    {
        return purchaseOrderMapper.deletePurchaseOrderByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除采购
     *
     * @param ids 需要软删除的采购主键
     * @return 结果
     */
    @Override
    public int softDeletePurchaseOrderByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            PurchaseOrder purchaseOrder = purchaseOrderMapper.selectPurchaseOrderById(Long.valueOf(s));
            purchaseOrder.setIsDelete(1);
            int i = purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除采购信息
     * 
     * @param id 采购主键
     * @return 结果
     */
    @Override
    public int deletePurchaseOrderById(Long id)
    {
        return purchaseOrderMapper.deletePurchaseOrderById(id);
    }
}
